package com.sgb.kjwl.view.ui.fragment.home;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.core.util.Pair;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.google.android.material.tabs.TabLayout;
import com.sgb.kjwl.BaseHeightViewPagerFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FrCorporateServicesBinding;
import com.sgb.kjwl.di.home.DaggerHomeFragComponent;
import com.sgb.kjwl.di.home.HomeFragModule;
import com.sgb.kjwl.model.entity.BannerEntity;
import com.sgb.kjwl.model.entity.ParentAreaEntity;
import com.sgb.kjwl.model.entity.enterprise.ServiceListEntiy;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.adapter.enterprise.ServiceListAdpater;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.kjwl.model.entity.enterprise.CompanyListEntity2;
import com.sgb.kjwl.model.entity.enterprise.CopyrightListEntity2;
import com.sgb.kjwl.model.entity.enterprise.IntellpropEntity;
import com.sgb.kjwl.model.entity.enterprise.ListBean;
import com.sgb.kjwl.model.entity.enterprise.PatentEntity;
import com.sgb.kjwl.model.entity.enterprise.PropertyEntity;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.view.event.CategoryEvent2;
import com.swgk.core.event.EventConstant;
import com.sgb.kjwl.view.ui.activity.enterprise.MakeOverDetailActivity;
import com.sgb.kjwl.view.ui.activity.enterprise.NewNeedDetailsActivity;
import com.sgb.kjwl.view.ui.adapter.enterprise.CompanyAdapter;
import com.sgb.kjwl.view.ui.adapter.enterprise.NeedNewAdapter;
import com.sgb.kjwl.view.ui.adapter.home.HomeIpCopyrightAdapter;
import com.sgb.kjwl.view.ui.adapter.home.HomePatentAdapter;
import com.sgb.kjwl.view.ui.adapter.home.HomePropertyAdapter;
import com.sgb.kjwl.view.ui.adapter.home.HomeTrademarkAdapter;
import com.sgb.kjwl.viewmodel.home.CorporateServicesModel;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

import javax.inject.Inject;

/*
 * 大首页企业服务
 * 2021/7/2 14:00
 * */
public class CorporateServicesFragment extends BaseHeightViewPagerFragment {

    @Inject
    CorporateServicesModel viewModel;

    private FrCorporateServicesBinding binding;

    private int mItemType;
    private int page = 1;

    //private EpQuoteAdapter epQuoteAdapter;//服务大厅
    private ServiceListAdpater serviceListAdpater;//新服务大厅
    //private NeedAdapter mNeedAdapter;//需求大厅
    private NeedNewAdapter mNeedNewAdapter;//新需求大厅
    private HomeTrademarkAdapter trademarkAdapter;//转让大厅--商标
    private HomeIpCopyrightAdapter ipCopyrightAdapter;//转让大厅--版权
    private HomePatentAdapter patentAdapter;//知产交易--专利
    private CompanyAdapter companyAdapter;//知产交易--公司
    private HomePropertyAdapter propertyAdapter;//知产交易--资产

    private ParentAreaEntity entity;
    private PickSelectEntity entity1;
    private PickSelectEntity entity2;

    public static CorporateServicesFragment newInstance(int position, BannerEntity bannerEntity, boolean isRefresh) {
        CorporateServicesFragment fragment = new CorporateServicesFragment();
        Bundle args = new Bundle();
        args.putSerializable(ARG_PARAM, bannerEntity);
        args.putInt(ARG_PARAM_POS, position);
        args.putBoolean(ARG_isRefresh, isRefresh);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() == null) {
            return;
        }
        mItemType = getItemType();
    }

    @Override
    public void onStart() {
        super.onStart();
        if (!EventBus.getDefault().isRegistered(getActivity())) {
            EventBus.getDefault().register(getActivity());
        }
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        DaggerHomeFragComponent.builder()
                .appComponent(appComponent)
                .homeFragModule(new HomeFragModule(this))
                .build()
                .inject(this);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fr_corporate_services, container, false);
        return binding.getRoot();
    }

    private int getItemType() {
        int mItemType = -1;
        BannerEntity bannerEntity = (BannerEntity) getArguments().getSerializable(ARG_PARAM);
        switch (bannerEntity.getName()) {
            case "服务大厅":
                mItemType = 0;
                break;
            case "需求大厅":
                mItemType = 1;
                break;
            case "知产交易":
                mItemType = 2;
                break;
        }
        return mItemType;
    }

    @Override
    protected void initView() {
        super.initView();
        if (getArguments() == null) {
            return;
        }
        mItemType = getItemType();
        if (mItemType == -1) {
            return;
        }
        binding.tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
        binding.recycler.setNestedScrollingEnabled(false);
        binding.recycler.setNestedScrollingEnabled(false);
        binding.recycler.setLayoutManager(new LinearLayoutManager(getActivity()));
      /*  binding.recycler.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.bottom = getResources().getDimensionPixelSize(R.dimen.dp1);
            }
        });*/
        serviceListAdpater = new ServiceListAdpater(getActivity(), null, false);
        serviceListAdpater.setOnItemClick(new AdapterOnItemClick<ServiceListEntiy>() {
            public void onItemClick(ServiceListEntiy serviceListEntiy, int position) {
                WebsiteInfoActivity.start(getActivity(), serviceListEntiy.getNo(), serviceListEntiy.getPromulgatorType() == 1 ? WebsiteInfoActivity.WEBSITE_FOR_COMPANY : WebsiteInfoActivity.WEBSITE_FOR_TEAM);
            }
        });
        mNeedNewAdapter = new NeedNewAdapter(getActivity(), null);
        mNeedNewAdapter.setOnItemClick(new AdapterOnItemClick<ListBean>() {
            @Override
            public void onItemClick(ListBean listBean, int position) {
                NewNeedDetailsActivity.startactivity(getActivity(), listBean.id + "");
            }
        });
        trademarkAdapter = new HomeTrademarkAdapter(getActivity(), null);
        trademarkAdapter.setOnItemClick(new AdapterOnItemClick<IntellpropEntity>() {
            @Override
            public void onItemClick(IntellpropEntity intellpropEntity, int p) {
                ActivityJump.jumpToActivity(getActivity(), MakeOverDetailActivity.class, Pair.create("detail", "商标"), Pair.create("id", intellpropEntity.getId()));
            }
        });
        ipCopyrightAdapter = new HomeIpCopyrightAdapter(getActivity(), null);
        ipCopyrightAdapter.setOnItemClick(new AdapterOnItemClick<CopyrightListEntity2>() {
            @Override
            public void onItemClick(CopyrightListEntity2 copyrightListEntity2, int p) {
                ActivityJump.jumpToActivity(getActivity(), MakeOverDetailActivity.class, Pair.create("detail", "版权"), Pair.create("id", copyrightListEntity2.getId()));
            }
        });
        patentAdapter = new HomePatentAdapter(getActivity(), null);
        patentAdapter.setOnItemClick(new AdapterOnItemClick<PatentEntity>() {
            @Override
            public void onItemClick(PatentEntity patentEntity, int p) {
                ActivityJump.jumpToActivity(getActivity(), MakeOverDetailActivity.class, Pair.create("detail", "专利"), Pair.create("id", patentEntity.getId()));
            }
        });
        companyAdapter = new CompanyAdapter(getActivity(), null, true);
        propertyAdapter = new HomePropertyAdapter(getActivity(), null);


        binding.tvMore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                loadData(true);
            }
        });
        binding.tvGoModel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 22));
            }
        });
        binding.tvGoModel1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 22));
            }
        });
    }

    @Override
    protected void onLazyLoad() {
        viewModel.getSecondType(mItemType);
    }

    public void IsRefresh(boolean isRefresh) {
        setIsRefresh(isRefresh);
        loadData(false);
    }

    private void loadData(boolean isLoadMore) {
        mItemType = getItemType();
        if (mItemType == -1) {
            return;
        }
        page = isLoadMore ? page + 1 : 1;
        switch (mItemType) {
            case 0: //服务大厅
                if (entity == null)
                    return;
                viewModel.getProfessQuoteList(isLoadMore, page, entity.getId(),mItemType);
                break;
            case 1: //需求大厅
                if (entity1 == null)
                    return;
                viewModel.getDemandHallList(isLoadMore, page, entity1.getNo());
                break;
            case 2: //知产交易
                if (entity2 == null)
                    return;
                switch (entity2.getProjectscale()) {
                    case "商标":
                        viewModel.trademarkList(isLoadMore, page);
                        break;
                    case "版权":
                        viewModel.getCopyrightList(isLoadMore, page);
                        break;
                    case "专利":
                        viewModel.getPatentList(isLoadMore, page);
                        break;
                    case "公司":
                        viewModel.getCompanyList(isLoadMore, page);
                        break;
                    case "资产":
                        viewModel.getPropertyList(isLoadMore, page);
                        break;
                    default:
                        break;
                }
                break;
        }
    }

    public void showServiceTypeView(List<ParentAreaEntity> datas) {
        binding.tabLayout.clearOnTabSelectedListeners();
        binding.tabLayout.removeAllTabs();
        if (!TextUtils.equals(datas.get(0).getName(), "全部"))
            datas.add(0, new ParentAreaEntity("", "全部", ""));
        for (int i = 0; i < datas.size(); i++) {
            binding.tabLayout.addTab(binding.tabLayout.newTab().setText(datas.get(i).getPickerViewText()));
        }
        binding.tabLayout.scrollTo(0, 0);
        entity = datas.get(0);
        binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                entity = datas.get(tab.getPosition());
                loadData(false);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
        loadData(false);
    }

    public void showDemandTypeView(List<PickSelectEntity> datas) {
        binding.tabLayout.clearOnTabSelectedListeners();
        binding.tabLayout.removeAllTabs();
        for (int i = 0; i < datas.size(); i++) {
            binding.tabLayout.addTab(binding.tabLayout.newTab().setText(datas.get(i).getProjectscale()));
        }
        binding.tabLayout.scrollTo(0, 0);
        entity1 = datas.get(0);
        binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                entity1 = datas.get(tab.getPosition());
                loadData(false);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
        loadData(false);
    }

    public void showTransferTypeView(List<PickSelectEntity> datas) {
        binding.tabLayout.clearOnTabSelectedListeners();
        binding.tabLayout.removeAllTabs();
        for (int i = 0; i < datas.size(); i++) {
            binding.tabLayout.addTab(binding.tabLayout.newTab().setText(datas.get(i).getProjectscale()));
        }
        binding.tabLayout.scrollTo(0, 0);
        entity2 = datas.get(0);
        binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                entity2 = datas.get(tab.getPosition());
                loadData(false);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
        loadData(false);
    }

    public void showQuoteList(List<ServiceListEntiy> list, boolean isLoadMore) {
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                serviceListAdpater.addDatas(list);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 3) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                }
            } else {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.tvMore.setVisibility(View.GONE);
                binding.recycler.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
            }
        } else {
            if (list != null && list.size() > 0) {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 3) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.VISIBLE);
                }
            } else {
                binding.lineMore.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.GONE);
            }
            serviceListAdpater.setDatas(list);
        }
        binding.recycler.setAdapter(serviceListAdpater);
    }

    public void getDemandHallList(List<ListBean> list, boolean isLoadMore) {
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                mNeedNewAdapter.addDatas(list);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 3) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                }

            } else {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.tvMore.setVisibility(View.GONE);
                binding.recycler.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
            }
        } else {
            if (list != null && list.size() > 0) {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 3) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.VISIBLE);
                }
            } else {
                binding.lineMore.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.GONE);
            }
            mNeedNewAdapter.setDatas(list);
        }
        binding.recycler.setAdapter(mNeedNewAdapter);
    }

    public void showTrademarkList(List<IntellpropEntity> list, boolean isLoadMore) {
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                trademarkAdapter.addDatas(list);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 6) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                }

            } else {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.tvMore.setVisibility(View.GONE);
                binding.recycler.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
            }
        } else {
            if (list != null && list.size() > 0) {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 6) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.VISIBLE);
                }
                binding.recycler.setLayoutManager(new GridLayoutManager(getActivity(), 2));
                binding.recycler.setPadding(0, 0, (int) getActivity().getResources().getDimension(R.dimen.dp10), 0);
            } else {
                binding.lineMore.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.GONE);
            }
            trademarkAdapter.setDatas(list);
        }
        binding.recycler.setAdapter(trademarkAdapter);
    }

    public void showCopyrightList(List<CopyrightListEntity2> list, boolean isLoadMore) {
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                ipCopyrightAdapter.addDatas(list);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 6) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                }

            } else {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.tvMore.setVisibility(View.GONE);
                binding.recycler.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
            }
        } else {
            if (list != null && list.size() > 0) {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 6) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.VISIBLE);
                }
                binding.recycler.setLayoutManager(new GridLayoutManager(getActivity(), 2));
                binding.recycler.setPadding(0, 0, (int) getActivity().getResources().getDimension(R.dimen.dp10), 0);
            } else {
                binding.lineMore.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.GONE);
            }
            ipCopyrightAdapter.setDatas(list);
        }
        binding.recycler.setAdapter(ipCopyrightAdapter);
    }

    public void showPatentList(List<PatentEntity> list, boolean isLoadMore) {
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                patentAdapter.addDatas(list);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 6) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                }

            } else {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.tvMore.setVisibility(View.GONE);
                binding.recycler.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
            }
        } else {
            if (list != null && list.size() > 0) {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 6) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.VISIBLE);
                }
                binding.recycler.setLayoutManager(new GridLayoutManager(getActivity(), 2));
                binding.recycler.setPadding(0, 0, (int) getActivity().getResources().getDimension(R.dimen.dp10), 0);
            } else {
                binding.lineMore.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.GONE);
            }
            patentAdapter.setDatas(list);
        }
        binding.recycler.setAdapter(patentAdapter);
    }

    public void getCompanyList(List<CompanyListEntity2> list, boolean isLoadMore) {
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                companyAdapter.addDatas(list);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 3) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                }

            } else {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.tvMore.setVisibility(View.GONE);
                binding.recycler.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
            }
        } else {
            if (list != null && list.size() > 0) {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 3) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.VISIBLE);
                }
                binding.recycler.setLayoutManager(new LinearLayoutManager(getActivity()));
                binding.recycler.setPadding(0, 0, 0, 0);
            } else {
                binding.lineMore.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.GONE);
            }
            companyAdapter.setDatas(list);
        }
        binding.recycler.setAdapter(companyAdapter);
    }

    public void getPropertyList(List<PropertyEntity> list, boolean isLoadMore) {
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                propertyAdapter.addDatas(list);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 6) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                }
            } else {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.tvMore.setVisibility(View.GONE);
                binding.recycler.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
            }
        } else {
            if (list != null && list.size() > 0) {
                binding.lineMore.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                if (list.size() < 6) {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.GONE);
                } else {
                    binding.lineMore.setVisibility(View.VISIBLE);
                    binding.tvMore.setVisibility(View.VISIBLE);
                }
                binding.recycler.setLayoutManager(new GridLayoutManager(getActivity(), 2));
                binding.recycler.setPadding(0, 0, (int) getActivity().getResources().getDimension(R.dimen.dp10), 0);
            } else {
                binding.lineMore.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
                binding.recycler.setVisibility(View.GONE);
            }
            propertyAdapter.setDatas(list);
        }
        binding.recycler.setAdapter(propertyAdapter);
    }
}
